import turtle


def tree(plist, l, a, f):
    """ plist is list of pens
    l is length of branch
    a is half of the angle between 2 branches
    f is factor by which branch is shortened
    from level to level."""
    if l > 15:
        lst = []
        for p in plist:
            p.forward(l)
            q = p.clone()
            p.left(a)
            q.right(a)
            lst.append(p)
            lst.append(q)
        tree(lst, l*f, a, f)


def main():
    p = turtle.Turtle()
    p.color("green")
    p.pensize(5)
    p.hideturtle() #隐藏画笔箭头

    #p.getscreen().tracer(150, 0) #第150次屏幕刷新会实际执行，0为没有延迟
    p.left(90)
    p.penup()  # Pull the pen up – no drawing when moving.
    p.goto(0, -200)
    p.pendown()  # Pull the pen down – drawing when moving. 这三条语句是一个组合相当于先把笔收起来再移动到指定位置，再把笔放下开始画

    t = tree([p], 200, 65, 0.6375)

    turtle.done()


main()
